package com.glory.eapequipmentmonitor.activity;

import android.os.Handler;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.glory.eapequipmentmonitor.R;
import com.glory.eapequipmentmonitor.adapter.CheckListAdapter;
import com.glory.eapequipmentmonitor.base.Constant;
import com.glory.eapequipmentmonitor.bean.CheckBean;
import com.pda.platform.ui.ui_pdaplatform.base.FreeUI_BaseActivity;
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_AddViewEntity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class CheckActivity extends FreeUI_BaseActivity {


    @BindView(R.id.tvUser)
    TextView tvUser;
    @BindView(R.id.rvThingList)
    RecyclerView rvThingList;
    @BindView(R.id.llMain)
    LinearLayout llMain;
    @BindView(R.id.tvEqpId)
    TextView tvEqpId;
    private CheckListAdapter checkListAdapter;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_check;
    }

    @Override
    protected void initView() {
        tvUser.setText(Constant.CURRENT_USER);
        tvEqpId.setText("EQP-001");
        freeUI_titleView.setTitle("点检");
        freeUI_titleView.setRightListener("提交", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showToast("提交成功", true);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        CheckActivity.this.finish();
                    }
                }, 2000);
            }
        });

        rvThingList.setLayoutManager(new LinearLayoutManager(CheckActivity.this));
        rvThingList.setItemAnimator(new DefaultItemAnimator());
        rvThingList.addItemDecoration(new DividerItemDecoration(CheckActivity.this, 1));
        checkListAdapter = new CheckListAdapter(null);
        checkListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        checkListAdapter.isFirstOnly(true);
        rvThingList.setAdapter(checkListAdapter);
    }

    @Override
    protected void initData() {
        List<CheckBean> list = new ArrayList<>();
        CheckBean checkBean = new CheckBean();
        checkBean.setTitle("点检项目1");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目1");
        list.add(checkBean);

        checkBean = new CheckBean();
        checkBean.setTitle("点检项目2");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目1");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目2");
        list.add(checkBean);

        checkBean = new CheckBean();
        checkBean.setTitle("点检项目3");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目1");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目2");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目3");
        list.add(checkBean);

        checkBean = new CheckBean();
        checkBean.setTitle("点检项目4");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目1");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目2");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目3");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目4");
        list.add(checkBean);

        checkBean = new CheckBean();
        checkBean.setTitle("点检项目5");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目1");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目2");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目3");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目4");
        list.add(checkBean);
        checkBean = new CheckBean();
        checkBean.setDataName("子项目5");
        list.add(checkBean);

        checkListAdapter.setNewData(list);
    }

    @Override
    protected FreeUI_AddViewEntity getBaseEntity() {
        return new FreeUI_AddViewEntity("header", llMain);
    }

}
